package com.dfe.backend.service;

import org.springframework.stereotype.Service;

import java.util.concurrent.ConcurrentHashMap;

/**
 * 【描述】：任务服务
 *
 * @author LiChang
 * @since 2025-8-8 8:45
 */
@Service
public class TaskStatusService {

    private final ConcurrentHashMap<String, Boolean> taskStatuses = new ConcurrentHashMap<>();

    public void startTask(String taskId) {
        taskStatuses.put(taskId, true);
        // 可以在这里触发异步任务
    }

    public boolean isTaskRunning(String taskId) {
        return taskStatuses.getOrDefault(taskId, false);
    }

    public void endTask(String taskId) {
        taskStatuses.remove(taskId);
    }

}
